/*******************************************************************************
*  file    : senddialog.cpp
*  created : 08.09.2013
*  author  : Slyshyk Oleksiy (alexSlyshyk@gmail.com)
*******************************************************************************/

#include "senddialog.hpp"
#include "ui_senddialog.h"
#include <QTableWidgetItem>

SendDialog::SendDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::SendDialog)
{
    ui->setupUi(this);
}

SendDialog::~SendDialog()
{
    delete ui;
}

void SendDialog::setData(const QVector<QStringList>& data)
{
    ui->tableWidget->setRowCount(0);
    ui->tableWidget->setColumnCount(3);
    QTableWidgetItem * item = 0;
    for( const QStringList& line : data)
        {
            int row_idx = ui->tableWidget->rowCount();
            ui->tableWidget->setRowCount(row_idx + 1);
            item = new QTableWidgetItem(line.at(0));
            ui->tableWidget->setItem(row_idx,0,item);
            item = new QTableWidgetItem(line.at(1));
            ui->tableWidget->setItem(row_idx,1,item);
            item = new QTableWidgetItem(line.at(2));
            ui->tableWidget->setItem(row_idx,2,item);
        }
}

QStringList SendDialog::items()
{
    QStringList res;
    res.reserve(ui->tableWidget->rowCount());
    for(int i = 0; i < ui->tableWidget->rowCount(); ++i)
        res << ui->tableWidget->item(i,1)->text();

    return res;
}
